package com.xyh;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.awt.*;

@RestController
@Configuration
public class MyController {
    @MyLoadBalanced
    @Bean
  public  RestTemplate tplA(){
        return new RestTemplate();
    };
    @RequestMapping(value = "/call",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
  public String call(){
    RestTemplate tpl=tplA();
    String json=tpl.getForObject("http://hello-server/call",String.class);
    return json;
  }
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
  public String hello(){
        return "你好世界";
  }
}
